﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using TyMES.Model.BaseInformation;
using TyMES.Model;

namespace TyMES.ViewModel.BaseInformation.RouteVMs
{
    public partial class RouteListVM : BasePagedListVM<Route_View, RouteSearcher>
    {
        
        protected override IEnumerable<IGridColumn<Route_View>> InitGridHeader()
        {
            return new List<GridColumn<Route_View>>{
                
                this.MakeGridHeader(x => x.Route_RouteCode).SetTitle(@Localizer["Page.工艺路径编码"].Value),
                this.MakeGridHeader(x => x.Route_RouteName).SetTitle(@Localizer["Page.工艺路径名称"].Value),
                this.MakeGridHeader(x => x.Route_RouteVersion).SetTitle(@Localizer["Page.工艺路径版本"].Value),
                this.MakeGridHeader(x => x.Route_ProductCode).SetTitle(@Localizer["Page.产品编号"].Value),
                this.MakeGridHeader(x => x.Route_Field2).SetTitle(@Localizer["Page.预留域2"].Value),
                this.MakeGridHeader(x => x.Route_Field3).SetTitle(@Localizer["Page.预留域3"].Value),
                this.MakeGridHeader(x => x.Route_Field4).SetTitle(@Localizer["Page.预留域4"].Value),
                this.MakeGridHeader(x => x.Route_Field5).SetTitle(@Localizer["Page.预留域5"].Value),

                this.MakeGridHeaderAction(width: 200)
            };
        }

        
        public override IOrderedQueryable<Route_View> GetSearchQuery()
        {
            var query = DC.Set<Route>()
                
                .CheckContain(Searcher.RouteCode, x=>x.RouteCode)
                .CheckContain(Searcher.RouteName, x=>x.RouteName)
                .CheckContain(Searcher.RouteVersion, x=>x.RouteVersion)
                .CheckContain(Searcher.ProductCode, x=>x.ProductCode)
                .CheckContain(Searcher.Field2, x=>x.Field2)
                .CheckContain(Searcher.Field3, x=>x.Field3)
                .CheckContain(Searcher.Field4, x=>x.Field4)
                .CheckContain(Searcher.Field5, x=>x.Field5)
                .Select(x => new Route_View
                {
				    ID = x.ID,
                    
                    Route_RouteCode = x.RouteCode,
                    Route_RouteName = x.RouteName,
                    Route_RouteVersion = x.RouteVersion,
                    Route_ProductCode = x.ProductCode,
                    Route_Field2 = x.Field2,
                    Route_Field3 = x.Field3,
                    Route_Field4 = x.Field4,
                    Route_Field5 = x.Field5,
                })
                .OrderBy(x => x.ID);
            return query;
        }

        
    }
    public class Route_View: Route
    {
        
        public string Route_RouteCode { get; set; }
        public string Route_RouteName { get; set; }
        public string Route_RouteVersion { get; set; }
        public string Route_ProductCode { get; set; }
        public string Route_Field2 { get; set; }
        public string Route_Field3 { get; set; }
        public string Route_Field4 { get; set; }
        public string Route_Field5 { get; set; }

    }

}